#pragma once

#ifndef FORCEREGISTRY_H
#define FORCEREGISTRY_H

#include <hash_map>
#include <list>
#include "Particle.h"
#include "ForceGenerator.h"

/**
 * Holds all the force generators and the particles that they apply to.
 */
class ForceRegistry
{
private:
	/** Holds the list of registrations. */
	static std::hash_map<Particle*, std::list<ForceGenerator*>*> registry;
	/** Instance of force registry. */
	static ForceRegistry* instance;
	ForceRegistry() { }
	~ForceRegistry();
public:
	/** Initialises the instance of the force generator. */
	static void init();
	/**
	 * Registers the given force generator to apply to the given
	 * particle.
	 */
	static void add(Particle* particle, ForceGenerator* force);
	/**
	 * Removes the given registered pair from the registry. If the
	 * pair is not registeredm this method will have no effect.
	 */
	static void remove(Particle* particle, ForceGenerator* force);
	/**
	 * Clears all the registrations from the registry. This will not
	 * delete the particles of the force generators themselves,
	 * just the records of thier connection.
	 */
	static void clear();
	/**
	 * Calls all the force generators to update the forces fo their
	 * corresponding particles.
	 */
	static void update(float frameTime);
};

#endif